﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VFTray
{
	internal class FeedTraySteps<T>
	{
		public FeedTraySteps()
		{
			Step = 0;
			Result = false;
			Runing = false;
		}
		internal bool Result { get; set; }
		internal bool Runing { get; set; }
		internal int Step { get; set; }

		private List<T> items = null;
		public List<T> Items => items;

		internal ThreadUtility.DelayHS DelayMove = new ThreadUtility.DelayHS();

		internal T Current = default(T);

		private int current_index = -1;
		internal bool GetNextMove()
		{
			if (items == null)
			{
				current_index = -1;
				Current = default(T);
				return false;
			}

			current_index++;
			if (items.Count > current_index)
			{
				Current = items[current_index];
				return true;
			}
			else
			{
				current_index = -1;
				Current = default(T);
				return false;
			}
		}

		internal void ClearMove(List<T> items)
		{
			if (items != null) this.items = items;
			Current = default(T);
			current_index = -1;
			Step = 0;
			Result = false;
			Runing = false;
		}
	}
}
